package com.example.myapplication2;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class ReceiveActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_receive);
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String date = extras.getString("date");
        String mess = extras.getString("mess");
        TextView viewById = findViewById(R.id.textView2);
        String format = String.format("接收到的消息:\n%s\n时间:\n%s",mess , date);
        viewById.setText(format);
        findViewById(R.id.back).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.back:
                Intent intent=new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("message","回应消息,,,,,,,,");
                intent.putExtras(bundle);
                setResult(Activity.RESULT_OK,intent);
                finish();
                break;
        }
    }
}